#define MAX_24BIT_UINT  ( (1<<24) - 1 )
#define MAX_32BIT_UINT  ( 0xFFFFFFFF )

#define EPSLON 1e-8f

#define PI 3.1415926
#define e 2.71828183

// techniques: has to match the define in cpp
#define SHADOW_NULL		0
#define SHADOW_SM		1	
#define SHADOW_PCFSM	2
#define SHADOW_SDSM		3
#define SHADOW_UFGVSM	4	
#define SHADOW_KBVSM	5

#define SHADING_RANDCOLOR	0
#define SHADING_COLOR		1
#define	SHADING_KAJIYA		2
//--------------------------------------------------------------------------------------
// Constant Buffers
//--------------------------------------------------------------------------------------
// const buffer 0
cbuffer cbPerFrame : register( b0 )
{
	matrix		g_mViewProj			: packoffset( c0 );
	matrix		g_mViewProjLight	: packoffset( c4 );

	float3		g_vEye				: packoffset( c8 );

	float4      g_AmbientLightColor : packoffset( c9 );

	float4		g_PointLightColor	: packoffset( c10 );
	float4		g_PointLightPos		: packoffset( c11 );
	
	float3		g_vLookAt			: packoffset( c12 );
	float		g_fvFov				: packoffset( c12.w );

	matrix		g_mInvViewProj		: packoffset(c13);
	matrix      g_mInvViewProjLight	: packoffset(c17);

	int			g_iTechShading		: packoffset(c21.x);
	int			g_iTechSM			: packoffset(c21.y);
    int         g_todo1             : packoffset(c21.z);
    int         g_todo2             : packoffset(c21.w);
};
// const buffer 1
cbuffer cbPerMaterial : register( b1 )
{
	float4		g_MatAmbient	: packoffset( c0 );
	float4		g_MatDiffuse	: packoffset( c1 ); 
	float4		g_MatSpecular	: packoffset( c2 );
};

//--------------------------------------------------------------------------------------
// SRV buffers
//--------------------------------------------------------------------------------------
Texture2D   g_txObj										: register( t0 );
Texture2D   g_txSMScene									: register( t1 );
Texture2D   g_txNoise			                        : register( t2 );

//--------------------------------------------------------------------------------------
// Samplers
//--------------------------------------------------------------------------------------
SamplerState				g_samLinearWrap				: register( s0 );
SamplerState				g_samLinearClamp			: register( s1 );
SamplerState				g_samPointClamp				: register( s2 );
SamplerComparisonState		g_samShadow					: register( s3 );

//--------------------------------------------------------------------------------------
// UAVs
//--------------------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// shader input/output structure
//--------------------------------------------------------------------------------------
struct VS_INPUT_SCENE
{
    float3 Position     : POSITION; // vertex position 
    float3 Normal       : NORMAL;   // this normal comes in per-vertex
    float2 Texcoord	    : TEXCOORD0;// vertex texture coords 
};

struct VS_OUTPUT_SM
{
    float4 Position     : SV_POSITION;
	float3 texPos		: TEXCOORD0;
};

struct VS_OUTPUT_SCENE
{
    float4 Position     : SV_POSITION; // vertex position
	float3 Normal		: TEXCOORD0;
	float2 Texcoord	    : TEXCOORD1;   // vertex texture coords 
	float3 texPos		: TEXCOORD2;
};

struct VS_OUTPUT_SCREENQUAD
{
    float4 vPosition : SV_POSITION;
    float2 vTex      : TEXCOORD;
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
VS_OUTPUT_SCREENQUAD VS_ScreenQuad(VS_INPUT_SCENE input)
{
	VS_OUTPUT_SCREENQUAD output;

    output.vPosition = float4(input.Position.xyz, 1.0);
    output.vTex = input.Texcoord.xy;

	return output;
}


#include "shadow.hlsl"